package cn.itsource.fallback;

import cn.itsource.api.DriverPointApi;
import cn.itsource.pojo.result.DriverPointResult;
import cn.itsource.result.JSONResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Slf4j
public class DriverPointApiFallback implements FallbackFactory<DriverPointApi> {

    @Override
    public DriverPointApi create(Throwable cause) {
        return new DriverPointApi(){

            @Override
            public JSONResult<List<DriverPointResult>> selectByOrderNo(String orderNo) {
                log.error("DriverPointApi 调用失败：{}", cause.getMessage(), cause);
                return JSONResult.error("服务调用失败["+cause.getMessage()+"]");
            }
        };
    }
}
